package com;

public class ReturnTimeFromType {
	
	/*This method converts the answer from TS (distance), into time  -taking into account 
	the mode of transport chosen in the GUI.*/
	
	static double getTime(double minDist) {
	
	//approximate the radius of the Earth at our latitude (Cam latitude is around 52 degrees).
	//we are assuming a spherical approximation for the Earth is suitable.
	double R = (6378 - 21 * Math.sin(52.0)) * 1000;
	
	//covert TS answer from radians to metres.
	double minDistMtrs = minDist * R;
	
	//convert answer from metres to minutes.
	double minTime = 0;
	//Say average walking speed: 90m/min so 1m/0.0111min.
	if (AlibiTesterApplet.type == "Walking") {
		minTime = minDistMtrs * 0.0111;
	}
	//Say average driving speed: 665m/min so 1m/0.001504min.
	else if (AlibiTesterApplet.type == "Driving") {
		minTime = minDistMtrs * 0.001504;
	}
	//Say average running speed: 270m/min so 1m/0.0037min.
	else if (AlibiTesterApplet.type == "Running") {
		minTime = minDistMtrs * 0.0037;
	}
			
	return minTime;		
	}

}
